package com.yundasys.lab06ratelimitannotation.controller;

import com.yundasys.lab06ratelimitannotation.limit.AccessLimiter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @PACKAGE_NAME: com.yundasys.lab06ratelimitannotation.controller
 * @NAME: AccessLimiterController
 * @USER: jiangta
 * @DATE: 2021/1/21
 * @TIME: 9:39 下午
 * @PROJECT_NAME: springboot-labs
 */
@RestController
@Slf4j
public class AccessLimiterController {

    @Autowired
    private AccessLimiter accessLimiter;

    @GetMapping("test")
    public String test() {
        accessLimiter.limitAccess("ratelimiter-test",1);
        return "success";
    }

    @GetMapping("test-annotation")
    @com.yundasys.lab06ratelimitannotation.annotation.AccessLimiter(limit = 1)
    public String testAnnotation() {

        return "success";
    }
}
